<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Sign in &laquo; Admin</title>
  <link rel="stylesheet" href="../assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="../assets/css/admin.css">
</head>
<body>
  <div class="login">
    <div class="login-wrap">
      <img class="avatar" src="../assets/img/default.png">
      <!-- 有错误信息时展示 -->
      <!-- <div class="alert alert-danger">
        <strong>错误！</strong> 用户名或密码错误！
      </div> -->
      <div class="form-group">
        <label for="email" class="sr-only">邮箱</label>
        <input id="email" type="email" class="form-control" id="email" placeholder="itheima@itcast.cn" value="itheima@itcast.cn" autofocus>
      </div>
      <div class="form-group">
        <label for="password" class="sr-only">密码</label>
        <input id="password" type="password" class="form-control" id="password" placeholder="123456" value="123456">
      </div>
      <button class="btn btn-primary btn-block" id="loginBtn">登 录</button>
    </div>
  </div>
  <script src="../assets/vendors/jquery/jquery.min.js"></script>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <script type="text/javascript">
    $('#loginBtn').click(async () => {
      if($('#email').val().trim() === '') return alert('邮箱不能为空。');
      if($('#password').val().trim() === '') return alert('密码不能为空。');
      const res_data =  await axios.post('/login', {
        // email:'itheima@itcast.cn',
        // password:'123456'
        email:$('#email').val(),
        password:$('#password').val()
      });
      location.href = 'index.html';
    });
  </script>
</body>
</html>
